package com.fast.common.druid;

import com.alibaba.druid.filter.config.ConfigTools;
import com.alibaba.druid.util.DruidPasswordCallback;

/**
 * 数据库密码回调解密
 * @author  杨浩泉
 * @version 2016年10月14日
 */
@SuppressWarnings("serial")
public class DBPasswordCallback extends DruidPasswordCallback {
	/*private static final byte[] key = { 9, -1, 0, 5, 39, 8, 6, 19 };

	public void setProperties(Properties properties) {
		super.setProperties(properties);
		String pwd = properties.getProperty("password");
		if (StringUtils.isNotBlank(pwd)) {
			try {
				String password = DigestUtils.sha1Hex(pwd);
				setPassword(password.toCharArray());
			} catch (Exception e) {
				setPassword(pwd.toCharArray());
			}
		}
	}*/

	// 请使用该方法加密后，把密文写入classpath:/config/jdbc.properties
	public static void main(String[] args) throws Exception {
		System.out.println(ConfigTools.encrypt("yhqmcq"));
		//System.out.println(DigestUtils.sha1Hex("yhqmcq"));
	}
}
